<template>
  <div>
    <detailBanner :sightName="sightName" :bannerImg="bannerImg" :gallaryImgs="gallaryImgs"></detailBanner>
    <detailHeader></detailHeader>
    <div class="content">
      <detailList :list="categoryList"></detailList>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import detailBanner from './components/banner'
import detailHeader from './components/header'
import detailList from './components/list'
export default {
  name: 'detail',
  components: {
    detailBanner,
    detailHeader,
    detailList
  },
  data () {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      categoryList: []
    }
  },
  activated () {
    this.getDetailInfo()
  },
  methods: {
    getDetailInfo () {
      axios.get('/static/json/detail.json', {
        id: this.$route.params.id
      }).then(this.getDetailInfoSuccess)
    },
    getDetailInfoSuccess (result) {
      if (result.status !== 200) alert('获取景点详细信息失败')
      const data = result.data.data
      this.sightName = data.sightName
      this.bannerImg = data.bannerImg
      this.gallaryImgs = data.gallaryImgs
      this.categoryList = data.categoryList
    }
  }
}
</script>

<style lang="stylus" scoped>
  .content
    height 20rem
</style>
